home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performRevolve.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  19.0 KB  |  639 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Mar 14, 1997
  22. //
  23. //
  24. //  Description:
  25. //      This script is defines the option box for the revolve menu item.
  26. //
  27. //  Input Arguments:
  28. //      int showOptionBox        true - show the option box dialog
  29. //                                false - just execute the revolve operation
  30. //
  31. //  Return Value:
  32. //      None.
  33. //
  34.  
  35. proc
  36. setOptionVars (int $forceFactorySettings)
  37. {
  38.     revolveSetOptionVars( $forceFactorySettings );
  39. }
  40.  
  41. global proc revolveSetup( string $parent,
  42.                           int $forceFactorySettings,
  43.                           string $goToTool )
  44. {
  45.     // Retrieve the option settings
  46.     //
  47.     setOptionVars ($forceFactorySettings);
  48.     revolveToolSetup( $forceFactorySettings, $goToTool );
  49.  
  50.     setParent $parent;
  51.  
  52.     // Query all of the optionVar's
  53.     //
  54.     int $usePresetAxis = `optionVar -q revolveUsePresetAxis` + 1;
  55.     float $axisX, $axisY, $axisZ;
  56.     switch( $usePresetAxis ) {
  57.         case 1: $axisX = 1; $axisY = 0; $axisZ = 0; break;
  58.         case 2: $axisX = 0; $axisY = 1; $axisZ = 0; break;
  59.         case 3: $axisX = 0; $axisY = 0; $axisZ = 1; break;
  60.         case 4:
  61.             $axisX = `optionVar -q revolveAxisX`;
  62.             $axisY = `optionVar -q revolveAxisY`;
  63.             $axisZ = `optionVar -q revolveAxisZ`;
  64.             break;
  65.     }
  66.     int $useObjectPivot = `optionVar -q revolveUseLocalPivot`;
  67.     float $pivotX, $pivotY, $pivotZ;
  68.     if( $useObjectPivot ) {
  69.         $pivotX = 0;
  70.         $pivotY = 0;
  71.         $pivotZ = 0;
  72.     }
  73.     else {
  74.         $pivotX = `optionVar -q revolvePivotX`;
  75.         $pivotY = `optionVar -q revolvePivotY`;
  76.         $pivotZ = `optionVar -q revolvePivotZ`;
  77.     }
  78.     float $startSweep = `optionVar -q revolveStartSweepAngle`;
  79.     float $endSweep = `optionVar -q revolveEndSweepAngle`;
  80.     int $degree = `optionVar -q revolveSurfaceDegree`;
  81.     switch( $degree ) {
  82.         case 1: $degree = 1; break;        // used below for degreeRadioButtonGrp
  83.         case 3: $degree = 2; break;        // used below for degreeRadioButtonGrp
  84.     }
  85.     int $useTol = `optionVar -q revolveUseTolerance`;
  86.     int $useGlobalTol = `optionVar -q revolveUseGlobalTol`;
  87.     float $tol = `optionVar -q revolveTolerance`;
  88.  
  89.     int $numSegments = `optionVar -q revolveNumberOfSegments`;
  90.     int $partialCrvRange = `optionVar -q revolveCurveRangePartial` + 1;
  91.     int $outputPolys = `optionVar -q revolveOutputPolygons`;
  92.     if( ! `isTrue "SurfaceUIExists"` ) $outputPolys = 1;
  93.  
  94.  
  95.     // Set the controls
  96.     //
  97.     radioButtonGrp -edit -select $usePresetAxis presetAxisRadioGroup;
  98.     radioButtonGrp -edit -select (2 - $useObjectPivot) pivotPointRadioGroup;
  99.     floatFieldGrp -edit -v1 $axisX axisFloatFieldGrp;
  100.     floatFieldGrp -edit -v2 $axisY axisFloatFieldGrp;
  101.     floatFieldGrp -edit -v3 $axisZ axisFloatFieldGrp;
  102.     floatFieldGrp -edit -v1 $pivotX pivotFloatFieldGrp;
  103.     floatFieldGrp -edit -v2 $pivotY pivotFloatFieldGrp;
  104.     floatFieldGrp -edit -v3 $pivotZ pivotFloatFieldGrp;
  105.     floatSliderGrp -edit -value $startSweep startSweepFloatSliderGrp;
  106.     floatSliderGrp -edit -value $endSweep endSweepFloatSliderGrp;
  107.     radioButtonGrp -edit -select $degree degreeRadioButtonGrp;
  108.     intSliderGrp -edit -value $numSegments segmentsIntSliderGrp;
  109.  
  110.     if( $useTol ) {
  111.         if( $useGlobalTol ) {
  112.             radioButtonGrp -edit -select 3 useTolerance;
  113.         }
  114.         else {
  115.             radioButtonGrp -edit -select 2 useTolerance;
  116.         }
  117.     }
  118.     else {
  119.         radioButtonGrp -edit -select 1 useTolerance;
  120.     }
  121.     floatSliderGrp -edit -value $tol toleranceFloatFieldGrp;
  122.  
  123.     radioButtonGrp -edit -select $partialCrvRange curveRangeRadioButtonGrp;
  124.     if( `isTrue "SurfaceUIExists"` ) {
  125.         if( (3 == $outputPolys) && ! `isTrue "SubdivUIExists"` ) {
  126.             $outputPolys = 2;
  127.         }
  128.         radioButtonGrp -edit -select ($outputPolys+1) outputPolyRadioButtonGrp;
  129.     }
  130.  
  131.  
  132.     // Disable and enable some sliders depending on other values
  133.     //
  134.     if( $usePresetAxis == 4 )
  135.         floatFieldGrp -e -enable 1 axisFloatFieldGrp;
  136.     else
  137.         floatFieldGrp -e -enable 0 axisFloatFieldGrp;
  138.     if( $useObjectPivot == 0 )
  139.         floatFieldGrp -e -enable 1 pivotFloatFieldGrp;
  140.     else
  141.         floatFieldGrp -e -enable 0 pivotFloatFieldGrp;
  142.  
  143.     if( $useTol ) {
  144.         tabLayout -e -selectTab useToleranceSlider tlTolerance;
  145.         if( $useGlobalTol ) {
  146.             tabLayout -e -selectTab tolGlobal tlUseGlobal;
  147.         }
  148.         else {
  149.             tabLayout -e -selectTab tolLocal tlUseGlobal;
  150.         }
  151.     }
  152.     else {
  153.         tabLayout -e -selectTab useToleranceNoSlider tlTolerance;
  154.     }
  155.  
  156.     switch( $outputPolys ) {
  157.       case 0:
  158.       default:
  159.         tabLayout -e -st polyOptionsNo polyOptions;
  160.         break;
  161.       case 1:
  162.         tabLayout -e -st polyOptionsOK polyOptions;
  163.         break;
  164.       case 2:
  165.         tabLayout -e -st polyOptionsSubdiv polyOptions;
  166.         break;
  167.       case 3:
  168.         tabLayout -e -st polyOptionsBezier polyOptions;
  169.         break;
  170.     }
  171.  
  172.     if( "" != $goToTool ) { 
  173.         checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
  174.           scriptToolExtraWidget;
  175.         checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
  176.           scriptToolExtraWidget;
  177.     }
  178.  
  179.     nurbsToPolySetup( $parent, $forceFactorySettings );
  180.     nurbsToSubdivSetup( $parent, $forceFactorySettings );
  181. }
  182.  
  183. global proc revolveCallback( string $parent, int $doIt, string $goToTool )
  184. {
  185.     if( "" != $goToTool ) {
  186.         optionVar -iv revolveEuc `scriptCtx -q -euc $goToTool`;
  187.         optionVar -iv revolveLac `scriptCtx -q -lac $goToTool`;
  188.     }
  189.     setParent $parent;
  190.  
  191.     // Get all the values from the controls
  192.     //
  193.     int $usePresetAxis = `radioButtonGrp -q -select presetAxisRadioGroup` - 1;
  194.     int $useObjectPivot = 2 - `radioButtonGrp -q -select pivotPointRadioGroup`;
  195.     float $axisX = `floatFieldGrp -q -v1 axisFloatFieldGrp`;
  196.     float $axisY = `floatFieldGrp -q -v2 axisFloatFieldGrp`;
  197.     float $axisZ = `floatFieldGrp -q -v3 axisFloatFieldGrp`;
  198.     float $pivotX = `floatFieldGrp -q -v1 pivotFloatFieldGrp`;
  199.     float $pivotY = `floatFieldGrp -q -v2 pivotFloatFieldGrp`;
  200.     float $pivotZ = `floatFieldGrp -q -v3 pivotFloatFieldGrp`;
  201.     float $startSw = `floatSliderGrp -q -value startSweepFloatSliderGrp`;
  202.     float $endSw = `floatSliderGrp -q -value endSweepFloatSliderGrp`;
  203.     int $degree = `radioButtonGrp -q -select degreeRadioButtonGrp`;
  204.     if( $degree == 1 ) $degree = 1; else $degree = 3;
  205.     int $segments = `intSliderGrp -q -value segmentsIntSliderGrp`;
  206.  
  207.     int $valUse = `radioButtonGrp -q -select useTolerance`;
  208.     switch( $valUse ) {
  209.       case 1:
  210.         optionVar -intValue revolveUseTolerance false;
  211.         break;
  212.       case 2:
  213.         optionVar -intValue revolveUseTolerance true;
  214.         optionVar -intValue revolveUseGlobalTol false;
  215.         break;
  216.       case 3:
  217.       default:
  218.         optionVar -intValue revolveUseTolerance true;
  219.         optionVar -intValue revolveUseGlobalTol true;
  220.         break;
  221.     }
  222.  
  223.  
  224.     float $tol = `floatSliderGrp -q -value toleranceFloatFieldGrp`;
  225.     int $useCrvRange = `radioButtonGrp -q -select curveRangeRadioButtonGrp` -1;
  226.     if( `isTrue "SurfaceUIExists"` ) {
  227.         int $outputPolys;
  228.         $outputPolys = `radioButtonGrp -q -select outputPolyRadioButtonGrp`;
  229.         if( (3 == $outputPolys) && ! `isTrue "SubdivUIExists"` ) {
  230.             $outputPolys = 4;
  231.         }
  232.         optionVar -intValue revolveOutputPolygons ($outputPolys-1);
  233.     }
  234.  
  235.     // Set all the corresponding option var's
  236.     //
  237.     optionVar -intValue revolveUsePresetAxis $usePresetAxis;
  238.     optionVar -intValue revolveUseLocalPivot $useObjectPivot;
  239.     if( $usePresetAxis == 3 ) {
  240.         optionVar -floatValue revolveAxisX $axisX;
  241.         optionVar -floatValue revolveAxisY $axisY;
  242.         optionVar -floatValue revolveAxisZ $axisZ;
  243.     }
  244.     if( !$useObjectPivot ) {
  245.         optionVar -floatValue revolvePivotX $pivotX;
  246.         optionVar -floatValue revolvePivotY $pivotY;
  247.         optionVar -floatValue revolvePivotZ $pivotZ;
  248.     }
  249.     optionVar -floatValue revolveStartSweepAngle $startSw;
  250.     optionVar -floatValue revolveEndSweepAngle $endSw;
  251.     optionVar -intValue revolveSurfaceDegree $degree;
  252.     optionVar -intValue revolveNumberOfSegments $segments;
  253.     optionVar -floatValue revolveTolerance $tol;
  254.     optionVar -intValue revolveCurveRangePartial $useCrvRange;
  255.  
  256.     nurbsToPolyCallback( $parent, 0 );
  257.     nurbsToSubdivCallback( $parent, 0 );
  258.  
  259.     if( 1 == $doIt ) {
  260.         performRevolve( 0, $goToTool ); 
  261.         string $tmpCmd = "performRevolve( 0, \"" + $goToTool + "\")";
  262.         addToRecentCommandQueue $tmpCmd "Revolve";
  263.     }
  264.     else if( $doIt ) {
  265.         setToolTo $goToTool;
  266.     }
  267. }
  268.  
  269. proc revolveOptions( int $inTheTool, string $goToTool )
  270. {
  271.     //    Name of the command for this option box.
  272.     //
  273.     string $commandName = "revolve";
  274.  
  275.     //    Build the option box actions.
  276.     //
  277.     string $callback = ($commandName + "Callback");
  278.     string $setup = ($commandName + "Setup");
  279.  
  280.     global string $gOptionBoxActionToolItem;
  281.     $gOptionBoxActionToolItem = "modelWithToolRevolve";
  282.     global string $gOptionBoxActionToolItemCB;
  283.     $gOptionBoxActionToolItemCB = "revolveToolScript 3";
  284.  
  285.     //    Step 1:  Get the option box.
  286.     //    ============================
  287.     string $layout = getOptionBox();
  288.     setParent $layout;
  289.  
  290.     //    Step 2:  Pass the command name to the option box.
  291.     //    =================================================
  292.     setOptionBoxCommandName($commandName);
  293.     
  294.     //    Step 3:  Activate the default UI template.
  295.     //    ==========================================
  296.     setUITemplate -pushTemplate DefaultTemplate;
  297.  
  298.     //    Step 4: Create option box contents.
  299.     //    ===================================
  300.     
  301.     //    Turn on the wait cursor.
  302.     //
  303.     waitCursor -state 1;
  304.  
  305.     tabLayout -scr true -tv false;
  306.     
  307.     string $parent = `columnLayout -adjustableColumn 1`;
  308.     
  309.     radioButtonGrp
  310.         -numberOfRadioButtons 4
  311.         -label "Axis Preset"
  312.         -label1 "X"
  313.         -label2 "Y"
  314.         -label3 "Z"
  315.         -label4 "Free"
  316.         presetAxisRadioGroup;
  317.     floatFieldGrp -l "Axis" -nf 3 axisFloatFieldGrp;
  318.         
  319.     radioButtonGrp
  320.         -numberOfRadioButtons 2
  321.         -label "Pivot"
  322.         -label1 "Object"
  323.         -label2 "Preset"
  324.         pivotPointRadioGroup;
  325.     floatFieldGrp -l "Pivot Point" -nf 3 pivotFloatFieldGrp;
  326.  
  327.     separator;
  328.  
  329.     radioButtonGrp
  330.         -numberOfRadioButtons 2
  331.         -label "Surface Degree"
  332.         -label1 "Linear"
  333.         -label2 "Cubic"
  334.         degreeRadioButtonGrp;
  335.  
  336.     floatSliderGrp -label "Start Sweep Angle" 
  337.         -min 0 -max 360.0 -field on startSweepFloatSliderGrp;
  338.     floatSliderGrp -label "End Sweep Angle" 
  339.         -min 0 -max 360.0 -field on endSweepFloatSliderGrp;
  340.  
  341.     radioButtonGrp -nrb 3 -l "Use Tolerance"
  342.         -l1 "None" -l2 "Local" -l3 "Global"
  343.         useTolerance;
  344.     tabLayout -tabsVisible false tlTolerance;
  345.         columnLayout useToleranceNoSlider;
  346.             intSliderGrp -label "Segments"
  347.                 -min 0 -field on segmentsIntSliderGrp;
  348.         setParent ..;
  349.         columnLayout useToleranceSlider;
  350.           tabLayout -tabsVisible false tlUseGlobal;
  351.             columnLayout tolLocal;
  352.                 floatSliderGrp -label "Tolerance" 
  353.                     -min 0.001 -max 1.0 -fmn 0.00001 -fmx 1000.0
  354.                     toleranceFloatFieldGrp;
  355.             setParent ..;
  356.             columnLayout tolGlobal;
  357.             setParent ..;
  358.           setParent ..;
  359.         setParent ..;
  360.     setParent ..;
  361.  
  362.     separator;
  363.  
  364.     radioButtonGrp -numberOfRadioButtons 2
  365.         -label "Curve Range"
  366.         -label1 "Complete"
  367.         -label2 "Partial"
  368.         curveRangeRadioButtonGrp;
  369.  
  370.     if( `isTrue "SubdivUIExists"` ) {
  371.         radioButtonGrp -nrb 4
  372.           -label "Output Geometry"
  373.           -label1 "Nurbs"
  374.           -label2 "Polygons"
  375.           -label3 "Subdiv"
  376.           -label4 "Bezier"
  377.           -cc1 "tabLayout -e -st polyOptionsNo polyOptions"
  378.           -cc2 "tabLayout -e -st polyOptionsOK polyOptions"
  379.           -cc3 "tabLayout -e -st polyOptionsSubdiv polyOptions"
  380.           -cc4 "tabLayout -e -st polyOptionsBezier polyOptions"
  381.           outputPolyRadioButtonGrp;
  382.     }
  383.     else if( `isTrue "SurfaceUIExists"` ) {
  384.         radioButtonGrp -nrb 3
  385.           -label "Output Geometry"
  386.           -label1 "Nurbs"
  387.           -label2 "Polygons"
  388.           -label3 "Bezier"
  389.           -cc1 "tabLayout -e -st polyOptionsNo polyOptions"
  390.           -cc2 "tabLayout -e -st polyOptionsOK polyOptions"
  391.           -cc3 "tabLayout -e -st polyOptionsBezier polyOptions"
  392.           outputPolyRadioButtonGrp;
  393.     }
  394.  
  395.     // Set the Axis float field grp to display only when Axis Preset is Free
  396.     //
  397.     string $enable = "floatFieldGrp -e -en 1 axisFloatFieldGrp;" +
  398.         "floatFieldGrp -e " +
  399.         "-value1 `optionVar -q revolveAxisX` " +
  400.         "-value2 `optionVar -q revolveAxisY` " +
  401.         "-value3 `optionVar -q revolveAxisZ` axisFloatFieldGrp; ";
  402.     string $disable = "floatFieldGrp -e -en 0 axisFloatFieldGrp;";
  403.     radioButtonGrp -edit
  404.         -cc1 ($disable + 
  405.                 "floatFieldGrp -e -value 1.0 0.0 0.0 0.0 axisFloatFieldGrp;")
  406.         -cc2 ($disable + 
  407.                 "floatFieldGrp -e -value 0.0 1.0 0.0 0.0 axisFloatFieldGrp;")
  408.         -cc3 ($disable + 
  409.                 "floatFieldGrp -e -value 0.0 0.0 1.0 0.0 axisFloatFieldGrp;")
  410.         -cc4 $enable
  411.         presetAxisRadioGroup;
  412.  
  413.     // Set the Pivot float field grp to display only when Pivot is Global
  414.     //
  415.     string $enableP = "floatFieldGrp -e -en 1 pivotFloatFieldGrp;" +
  416.         "floatFieldGrp -e " +
  417.         "-value1 `optionVar -q revolvePivotX` " +
  418.         "-value2 `optionVar -q revolvePivotY` " +
  419.         "-value3 `optionVar -q revolvePivotZ` pivotFloatFieldGrp;";
  420.     string $disableP = "floatFieldGrp -e -en 0 pivotFloatFieldGrp;";
  421.     radioButtonGrp -edit -cc1 $disableP -cc2 $enableP pivotPointRadioGroup;
  422.  
  423.     // Set the "Use Tolerance" checkbox so that if the checkbox is on, 
  424.     // then the tolerance slider is visible.
  425.     //
  426.     radioButtonGrp -edit
  427.         -on1 ( "tabLayout -e -selectTab useToleranceNoSlider tlTolerance;" )
  428.         -on2 ( "tabLayout -e -selectTab useToleranceSlider tlTolerance;" +
  429.                "tabLayout -e -selectTab tolLocal tlUseGlobal;" )
  430.         -on3 ( "tabLayout -e -selectTab useToleranceSlider tlTolerance;" +
  431.                "tabLayout -e -selectTab tolGlobal tlUseGlobal;" )
  432.         useTolerance;
  433.  
  434.  
  435.     separator;
  436.  
  437.     tabLayout -tabsVisible false polyOptions;
  438.       string $par = `columnLayout polyOptionsOK`;
  439.         nurbsToPolyAddOptions $par;
  440.       setParent ..;
  441.       columnLayout polyOptionsNo;
  442.       setParent ..;
  443.       columnLayout polyOptionsSubdiv;
  444.         nurbsToSubdivAddOptions $par;
  445.       setParent ..;
  446.       columnLayout polyOptionsBezier;
  447.       setParent ..;
  448.     setParent ..;
  449.  
  450.     if( $inTheTool ) {
  451.         separator;
  452.         checkBoxGrp -ncb 2 -l "Tool Behavior"
  453.           -l1 "Exit on Completion"
  454.           -v1 off
  455.           -on1 ("scriptCtx -e -euc true " + $goToTool)
  456.           -of1 ("scriptCtx -e -euc false " + $goToTool)
  457.  
  458.           -l2 "Auto Completion"
  459.           -v2 on
  460.           -on2 ("scriptCtx -e -lac true " + $goToTool)
  461.           -of2 ("scriptCtx -e -lac false " + $goToTool)
  462.           scriptToolExtraWidget;
  463.     }
  464.  
  465.     //    Turn off the wait cursor.
  466.     //
  467.     waitCursor -state 0;
  468.     
  469.     //    Step 5: Deactivate the default UI template.
  470.     //  ===========================================
  471.     //
  472.     setUITemplate -popTemplate;
  473.  
  474.     //    Step 6: Customize the buttons.  
  475.     //    ==============================
  476.  
  477.     //    'Apply' button.
  478.     //
  479.     string $applyBtn = getOptionBoxApplyBtn();
  480.     if( $inTheTool ) {
  481.         button -edit -l "Revolve Tool"
  482.             -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
  483.             $applyBtn;
  484.     }
  485.     else {
  486.         button -edit -l "Revolve"
  487.             -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
  488.             $applyBtn;
  489.     }
  490.  
  491.     //    'Save' button.
  492.     //
  493.     string $saveBtn = getOptionBoxSaveBtn();
  494.     button -edit 
  495.         -command ($callback + " " + $parent + " 0 \"" +
  496.                   $goToTool + "\"; hideOptionBox")
  497.         $saveBtn;
  498.  
  499.     //    'Reset' button.
  500.     //
  501.     string $resetBtn = getOptionBoxResetBtn();
  502.     button -edit 
  503.         -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
  504.         $resetBtn;
  505.  
  506.     //    Step 7: Set the option box title.
  507.     //    =================================
  508.     //
  509.     if( $inTheTool ) {
  510.         setOptionBoxTitle("Revolve Tool Options");
  511.     }
  512.     else {
  513.         setOptionBoxTitle("Revolve Options");
  514.     }
  515.  
  516.     //    Step 8: Customize the 'Help' menu item text.
  517.     //    ============================================
  518.     //
  519.     setOptionBoxHelpTag( "Revolve" );
  520.  
  521.     //    Step 9: Set the current values of the option box.
  522.     //    =================================================
  523.     //
  524.     eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");    
  525.     
  526.     //    Step 10: Show the option box.
  527.     //    =============================
  528.     //
  529.     showOptionBox();
  530. }
  531.  
  532. //
  533. //  Procedure Name:
  534. //      revolveHelp
  535. //
  536. //  Description:
  537. //        Return a short description about this command.
  538. //
  539. //  Input Arguments:
  540. //      None.
  541. //
  542. //  Return Value:
  543. //      string.
  544. //
  545.  
  546. proc string revolveHelp()
  547. {
  548.     return 
  549.     "  Command: Revolve - create surface from a curve\n" +
  550.     "Selection: curve, curve on surface, surface isoparm";
  551. }
  552.  
  553. proc string assembleCmd()
  554. {
  555.     string $cmd;
  556.  
  557.     setOptionVars( false );
  558.  
  559.     int $usePresetAxis = `optionVar -q revolveUsePresetAxis`;
  560.     float $axisX, $axisY, $axisZ;
  561.     switch( $usePresetAxis ) {
  562.         case 0: $axisX = 1; $axisY = 0; $axisZ = 0; break;
  563.         case 1: $axisX = 0; $axisY = 1; $axisZ = 0; break;
  564.         case 2: $axisX = 0; $axisY = 0; $axisZ = 1; break;
  565.         case 3: 
  566.             $axisX = `optionVar -q revolveAxisX`;
  567.             $axisY = `optionVar -q revolveAxisY`;
  568.             $axisZ = `optionVar -q revolveAxisZ`;
  569.             break;
  570.     }
  571.     int $useObjectPivot = `optionVar -q revolveUseLocalPivot`;
  572.     float $pivotX, $pivotY, $pivotZ;
  573.     switch( $useObjectPivot ) {
  574.         case 1: $pivotX = 0; $pivotY = 0; $pivotZ = 0; break;
  575.         case 0: 
  576.             $pivotX = `optionVar -q revolvePivotX`;
  577.             $pivotY = `optionVar -q revolvePivotY`;
  578.             $pivotZ = `optionVar -q revolvePivotZ`;
  579.             break;
  580.     }
  581.     float $startSweep = `optionVar -q revolveStartSweepAngle`;
  582.     float $endSweep = `optionVar -q revolveEndSweepAngle`;
  583.     int $degree = `optionVar -q revolveSurfaceDegree`;
  584.     int $useTol = `optionVar -q revolveUseTolerance`;
  585.     float $tol = `optionVar -q revolveTolerance`;
  586.     if( `optionVar -q revolveUseGlobalTol` ) {
  587.         $tol = `optionVar -q positionalTolerance`;
  588.     }
  589.     int $numSegments = `optionVar -q revolveNumberOfSegments`;
  590.     int $partialCrvRange = `optionVar -q revolveCurveRangePartial`;
  591.     int $outputPolys = `optionVar -q revolveOutputPolygons`;
  592.     if( ! `isTrue "SurfaceUIExists"` ) $outputPolys = 1;
  593.     int $doHistory = `constructionHistory -q -tgl`;
  594.  
  595.     // Piece together the revolve command
  596.     //
  597.     string $cmd;
  598.     $cmd = ( "revolvePreset " +
  599.              $doHistory + " " + $outputPolys + " " + $partialCrvRange + " " +
  600.              $startSweep + " " + $endSweep  + " " + $useTol + " " + $tol + " " +
  601.              $degree + " " + $numSegments  + " " + $useObjectPivot + " " +
  602.              $axisX + " " + $axisY +  " " + $axisZ + " " +
  603.              $pivotX + " " + $pivotY +  " " + $pivotZ );
  604.     return $cmd;
  605. }
  606.  
  607. // The action variable means
  608. //      0 - Execute the command.
  609. //      1 - Show the option box dialog.
  610. //      2 - Return the command.
  611. //      3 - Show the tool option box dialog.
  612.  
  613. global proc string performRevolve( int $action, string $goToTool )
  614. {
  615.     int $inTheTool = false;
  616.     if( 3 == $action ) {
  617.         $action = 1;
  618.         $inTheTool = true;
  619.     }
  620.  
  621.     string $cmd = "";
  622.     switch ($action) {
  623.       case 0:
  624.         setOptionVars (false);
  625.         $cmd = `assembleCmd`;
  626.         eval($cmd);
  627.         break;
  628.       case 1:
  629.         revolveOptions( $inTheTool, $goToTool );
  630.         break;
  631.       case 2:
  632.       default:
  633.         setOptionVars (false);
  634.         $cmd = `assembleCmd`;
  635.         break;
  636.     }
  637.     return $cmd;
  638. }
  639.